package com.qq.xqj.service.impl;

import com.qq.xqj.mapper.Car_mapper;
import com.qq.xqj.mapper.Order_mapper;
import com.qq.xqj.modle.Order_info;
import com.qq.xqj.service.Order_service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Order_serviceImpl implements Order_service {
    @Autowired
    Order_mapper order_mapper;
    @Autowired
    Car_mapper car_mapper;


    @Override
    public List<Order_info> getALLOrder() {
        return order_mapper.queryAllOrder();
    }

    @Override
    public int deleteOrderById(String orderId) {
        return order_mapper.deleteOrderById(orderId);
    }

    @Override
    public Order_info queryOrderById(int orderId) {
        return order_mapper.queryOrderById(orderId);
    }

    @Override
    public int updateOrderById(Order_info order_info) {
        return order_mapper.updateOrderById(order_info);
    }

    @Override
    public int addOrder(Order_info order_info) {
        return order_mapper.addOrder(order_info);
    }

    @Override
    public List<Order_info> queryOrderByKey(Order_info order_info) {
        return order_mapper.queryOrderByKey(order_info);
    }

    @Override
    public void queryTotal(Order_info order_info) {
        String brand = order_info.getBrand();
        String type = order_info.getType();
        String color = order_info.getColor();
        System.out.println(brand);
        System.out.println(type);
        System.out.println(color);
        int i = car_mapper.queryTotal(brand,type,color);
        System.out.println(i);
        if (car_mapper.queryTotal(brand,type,color) <= 0){
            throw new RuntimeException();
        }
        else {
            car_mapper.updateTotal(brand,type,color);
        }
    }

//    @Override
//    public List<Order_info> queryAllOrder() {
//        return order_mapper.queryAllOrder();
//    }



    }

